import HttpClient from '../../utils/httpClient';

export function getUsers(data, success, error) {
  HttpClient.request({
    url: '/user/findAll',
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function createUser(data, success, error) {
  HttpClient.request({
    method: 'post',
    url: '/user/create',
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function userDetail(id, success, error) {
  HttpClient.request({
    url: `/user/detail/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function updateUser(id, data, success, error) {
  HttpClient.request({
    method: 'put',
    url: `/user/update/${id}`,
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function deleteUser(id, success, error) {
  HttpClient.request({
    method: 'delete',
    url: `/user/delete/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function updatePassword(id, data, success, error) {
  HttpClient.request({
    method: 'put',
    url: `/user/updatePassword/${id}`,
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function disabledUser(id, data, success, error) {
  HttpClient.request({
    method: 'put',
    url: `/user/disabled/${id}`,
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

